<?php
/*
 * Created on 2012-7-15
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */
class add_comment extends MY_Controller{
	function __construct(){
		parent::__construct();
	}
	function index($fid=''){
		$captcha = $this->session->userdata('captcha');
		if($captcha != $this->input->post('captcha'))
		{
			redirect($this->input->post('current_url').'?replay='.$captcha);
		}
		$data['article_id'] = $this->input->post('article_id');
		//如果是回复的评论，则$fid!=''
		$data['fid'] = $fid;
		$author = $this->session->userdata('username');
		$this->load->model("user_m");
		$data['user_id'] = $this->user_m->get_id_by_username($author)->result();
		$data['user_id'] = $data['user_id']['0']->userid;
		$data['content'] = $this->input->post('content');
		$data['commentor_ip'] = $this->session->userdata('ip_address');
		$this->load->model('comment_m');
		if($this->comment_m->add_comment($data)){
			redirect($this->input->post('current_url').'?replay=1');
		}else{
			redirect($this->input->post('current_url').'?replay=2');
		}
		}
	}

?>

